package com.bosssoft.trainee.nontax.config;

import com.bosssoft.trainee.nontax.util.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author liuqiang
 * @date 2022/6/19 16:09
 * 配置拦截器
 */
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    /**
     * add..拦截-"/**"指拦截所有请求
     * exclude..放行
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/", "login");

    }

    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }
}
